STOP_WORD NLTK

by: Sandeep Thakuri, 7 years ago


[from nltk.corpus import stopwords
from nltk.tokenize import word_tokenize

example_sent = "This is a sample sentence, showing off the stop words filtration."

stop_words = set(stopwords.words('english'))

word_tokens = word_tokenize(example_sent)

filtered_sentence = [w for w in word_tokens if not w in stop_words]




print(filtered_sentence)]



File "C:/Users/IBM/PycharmProjects/untitled1/stop_words.py", line 1, in <module>
    from nltk.corpus import stopwords
  File "C:UsersIBMAppDataRoamingPythonPython36site-packagesnltk__init__.py", line 89, in <module>
    from nltk.internals import config_java
  File "C:UsersIBMAppDataRoamingPythonPython36site-packagesnltkinternals.py", line 11, in <module>
    import subprocess
  File "C:UsersIBMAppDataLocalProgramsPythonPython36-32libsubprocess.py", line 126, in <module>
    import threading
  File "C:UsersIBMAppDataLocalProgramsPythonPython36-32libthreading.py", line 7, in <module>
    from traceback import format_exc as _format_exc
  File "C:UsersIBMAppDataLocalProgramsPythonPython36-32libtraceback.py", line 5, in <module>
    import linecache
  File "C:UsersIBMAppDataLocalProgramsPythonPython36-32liblinecache.py", line 11, in <module>
    import tokenize
  File "C:UsersIBMPycharmProjectsuntitled1tokenize.py", line 1, in <module>
    from nltk.tokenize import sent_tokenize, word_tokenize
  File "C:UsersIBMAppDataRoamingPythonPython36site-packagesnltktokenize__init__.py", line 67, in <module>
    from nltk.tokenize.mwe      import MWETokenizer
  File "C:UsersIBMAppDataRoamingPythonPython36site-packagesnltktokenizemwe.py", line 31, in <module>
    from nltk.util import Trie



You must be logged in to post. Please login or register an account.